<?php
namespace app\rpc\controllers;

use app\rpc\models\UserModel;
use lib\rule\ParentInit;

class UserController extends ParentInit {

    public function getUserLoginByUserPass($user_name,$pass_word,$is_admin = 0){
        $data = UserModel::find()->where([['=','user_name',$user_name],['=','pass_word',$pass_word]],'and')->one()?:[];
        if ($is_admin && !$data[0]['is_admin'])return ['code'=>400,'message'=>'密码错误!'];
        UserModel::find()->where([['=','user_name',$user_name],['=','pass_word',$pass_word]],'and')->update(['last_login_time'=>time()]);
        return  ['code'=>200,'message'=>'成功','data'=>$data[0]];
    }
}